package br.com.ppj.util;

import org.xml.sax.ErrorHandler;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;

public class XMLErrorHandler implements ErrorHandler {

	private int count = 0;
	private String message = "";

	public void warning(SAXParseException exc) throws SAXException {
        printException(exc);
    }

	public void error(SAXParseException exc) throws SAXException {
		printException(exc);
	}

	public void fatalError(SAXParseException exc) throws SAXException {
		printException(exc);
	}

	private void printException(SAXParseException exc) {
		count++;
	    this.message += "linha:"  + exc.getLineNumber() + 
	                    "\ncoluna:" + exc.getColumnNumber() + 
	                    "\nerror: " + exc.getLocalizedMessage(); 
	                     
	}

	public int getCount() {
		return count;
	}

	public void setCount(int count) {
		this.count = count;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}
}